import unittest

from parameterized import parameterized

from api.ihrm_emp_crud_api import IhrmEmpCRUDApi
from api.ihrm_login_api import IhrmLoginApi
from config import TEL

from uilts.common_asserts import comm_asserts
from uilts.db_util import DBUtils
from uilts.get_token import get_login_token
from uilts.read_data import read_login_data


class TestEmpAdd(unittest.TestCase):
    token = None

    @classmethod
    def setUpClass(cls):
        if cls.token is None:
            cls.token = get_login_token()


    @classmethod
    def tearDownClass(cls):
        if cls.token is not None:
            cls.token = None


    def setUp(self):
        DBUtils.uid_dblist(F"delete from bs_user where mobile = '{TEL}'")

    def tearDown(self):
        DBUtils.uid_dblist(F"delete from bs_user where mobile = '{TEL}'")

    @parameterized.expand(read_login_data("add_emp_data"))
    def test_add_emp(self, emp_data, status_code, success, code, message):
        resp = IhrmEmpCRUDApi.add_emp(self.token, emp_data)
        comm_asserts(self, resp, status_code, success, code, message)
